import request from '../utils/request'

export default {
    namespace: "home",
    state: [],
    reducers: {
        add(state) {
            state += 1
            return state
        },
        setList(state, { res }) {
            state = res
            return state
        }
    },
    // 异步修改数据
    effects: {
        *init(action, { put, call }) {
            // console.log(action)
            let res = yield request("https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata")
            yield put({ type: "setList", res: res.data.message })
            // 
            // yield call(() => {
            //     request("https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata")
            //     console.log(12)
            // })
        }
    },
    subscriptions: {
        
        // aaaaaaaaaaa({ dispatch, history }) {
        //     console.log(history)
        //     dispatch({ type: "init" })
        // }
    }
}